ostree_sysroot_cleanup
ostree_sysroot_prepare_cleanup
ostree_sysroot_get_repo
+ostree_sysroot_init_osname
ostree_sysroot_deployment_set_kargs
ostree_sysroot_write_deployments
ostree_sysroot_deploy_tree
global:
ostree_repo_get_dfd;
ostree_repo_list_refs_ext;
+ ostree_sysroot_init_osname;
} LIBOSTREE_2016.3;
requires_new_bootversion ? "yes" : "no",
new_deployments->len - self->deployments->len);
- /* Allow other systems to monitor for changes */
- if (utimensat (self->sysroot_fd, "ostree/deploy", NULL, 0) < 0)
- {
- glnx_set_prefix_error_from_errno (error, "%s", "futimens");
- goto out;
- }
+ if (!_ostree_sysroot_bump_mtime (self, error))
+ goto out;
/* Now reload from disk */
if (!ostree_sysroot_load (self, cancellable, error))
GCancellable *cancellable,
GError **error);
+gboolean _ostree_sysroot_bump_mtime (OstreeSysroot *sysroot,
+ GError **error);
+
typedef enum {
OSTREE_SYSROOT_CLEANUP_BOOTVERSIONS = 1 << 0,
OSTREE_SYSROOT_CLEANUP_DEPLOYMENTS = 1 << 1,
return self->sysroot_fd;
}
+gboolean
+_ostree_sysroot_bump_mtime (OstreeSysroot *self,
+ GError **error)
+{
+ /* Allow other systems to monitor for changes */
+ if (utimensat (self->sysroot_fd, "ostree/deploy", NULL, 0) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "%s", "futimens");
+ return FALSE;
+ }
+ return TRUE;
+}
+
/**
* ostree_sysroot_unload:
* @self: Sysroot
return g_task_propagate_boolean ((GTask*)result, error);
}
+/**
+ * ostree_sysroot_init_osname:
+ * @self: Sysroot
+ * @osname: Name group of operating system checkouts
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Initialize the directory structure for an "osname", which is a
+ * group of operating system deployments, with a shared `/var`. One
+ * is required for generating a deployment.
+ */
+gboolean
+ostree_sysroot_init_osname (OstreeSysroot *self,
+ const char *osname,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ const char *deploydir = glnx_strjoina ("ostree/deploy/", osname);
+ glnx_fd_close int dfd = -1;
+
+ if (!ensure_sysroot_fd (self, error))
+ goto out;
+
+ if (mkdirat (self->sysroot_fd, deploydir, 0777) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Creating %s", deploydir);
+ goto out;
+ }
+
+ if (!glnx_opendirat (self->sysroot_fd, deploydir, TRUE, &dfd, error))
+ goto out;
+
+ if (mkdirat (dfd, "var", 0777) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Creating %s", "var");
+ goto out;
+ }
+
+ /* This is a bit of a legacy hack...but we have to keep it around
+ * now. We're ensuring core subdirectories of /var exist.
+ */
+ if (mkdirat (dfd, "var/tmp", 0777) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Creating %s", "var/tmp");
+ goto out;
+ }
+
+ if (fchmodat (dfd, "var/tmp", 01777, 0) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Fchmod %s", "var/tmp");
+ goto out;
+ }
+
+ if (mkdirat (dfd, "var/lib", 0777) < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Creating %s", "var/tmp");
+ goto out;
+ }
+
+ if (symlinkat ("../run", dfd, "var/run") < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Symlinking %s", "var/run");
+ goto out;
+ }
+
+ if (symlinkat ("../run/lock", dfd, "var/lock") < 0)
+ {
+ glnx_set_prefix_error_from_errno (error, "Symlinking %s", "var/lock");
+ goto out;
+ }
+
+ if (!_ostree_sysroot_bump_mtime (self, error))
+ goto out;
+
+ ret = TRUE;
+ out:
+ return ret;
+}
+
/**
* ostree_sysroot_simple_write_deployment:
* @sysroot: Sysroot
_OSTREE_PUBLIC
void ostree_sysroot_unlock (OstreeSysroot *self);
+_OSTREE_PUBLIC
+gboolean ostree_sysroot_init_osname (OstreeSysroot *self,
+ const char *osname,
+ GCancellable *cancellable,
+ GError **error);
+
_OSTREE_PUBLIC
gboolean ostree_sysroot_cleanup (OstreeSysroot *self,
GCancellable *cancellable,
glnx_unref_object OstreeSysroot *sysroot = NULL;
gboolean ret = FALSE;
const char *osname = NULL;
- g_autoptr(GFile) deploy_dir = NULL;
- g_autoptr(GFile) dir = NULL;
context = g_option_context_new ("OSNAME - Initialize empty state for given operating system");
osname = argv[1];
- deploy_dir = ot_gfile_get_child_build_path (ostree_sysroot_get_path (sysroot), "ostree", "deploy", osname, NULL);
-
- /* Ensure core subdirectories of /var exist, since we need them for
- * dracut generation, and the host will want them too.
- */
- g_clear_object (&dir);
- dir = ot_gfile_get_child_build_path (deploy_dir, "var", "tmp", NULL);
- if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
- goto out;
- if (chmod (gs_file_get_path_cached (dir), 01777) < 0)
- {
- gs_set_error_from_errno (error, errno);
- goto out;
- }
-
- g_clear_object (&dir);
- dir = ot_gfile_get_child_build_path (deploy_dir, "var", "lib", NULL);
- if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
+ if (!ostree_sysroot_init_osname (sysroot, osname, cancellable, error))
goto out;
- g_clear_object (&dir);
- dir = ot_gfile_get_child_build_path (deploy_dir, "var", "run", NULL);
- if (!g_file_test (gs_file_get_path_cached (dir), G_FILE_TEST_IS_SYMLINK))
- {
- if (symlink ("../run", gs_file_get_path_cached (dir)) < 0)
- {
- gs_set_error_from_errno (error, errno);
- goto out;
- }
- }
-
- dir = ot_gfile_get_child_build_path (deploy_dir, "var", "lock", NULL);
- if (!g_file_test (gs_file_get_path_cached (dir), G_FILE_TEST_IS_SYMLINK))
- {
- if (symlink ("../run/lock", gs_file_get_path_cached (dir)) < 0)
- {
- gs_set_error_from_errno (error, errno);
- goto out;
- }
- }
-
- g_print ("%s initialized as OSTree root\n", gs_file_get_path_cached (deploy_dir));
+ g_print ("ostree/deploy/%s initialized as OSTree root\n", osname);
ret = TRUE;
out: